Fix/stream contract dead code cleanup#593
Open
devfoma wants to merge 2 commits into
Open
Conversation
The withdraw function contained an unreachable second if stream.paused guard immediately after an identical first check. Since validate_stream_active and the first paused guard already cause an early return, the second block was dead code. Remove it to improve readability and reduce WASM size.
…irectory Remove the stale contracts/stream_contract/src/stream_contract/ subtree. This nested directory was never wired into the crate module tree (lib.rs declares mod test; which resolves to src/test.rs, not this path), so the 61-line fuzz_stream_invariants stub it contained was never compiled or run. The four arithmetic invariants it tested (withdrawn<=deposited, claimable<= remaining, non-negative accrual, cancel_refund+withdrawn<=deposited) are already covered by test_fuzz_withdrawn_never_exceeds_deposited, test_fuzz_claimable_never_exceeds_remaining, test_fuzz_cancel_early_refunds, and test_fuzz_claimable_overflow_and_cancel_invariants in src/test.rs.
Contributor
|
hey, #706 just merged and fixes a broken test-mock pattern that was causing 'Failed Suites' / 'is not a function' / '0 tests' on backend integration tests. please rebase to pick it up: git fetch upstream
git rebase upstream/main
git push --force-with-lease |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pure dead-code cleanup in
contracts/stream_contract. Two self-contained fixes, one commit each. No logic changes, no test changes.Fix 1 — Remove duplicate
if stream.pausedguard inwithdrawFixes #534
The
withdrawfunction had two back-to-back identical guards:Because the first
if stream.pausedblock always returns early whentrue, the second block was unreachable. It was removed, leaving the single correct check in place.Impact: No behaviour change. Reduces compiled WASM size by 3 lines of redundant bytecode. Eliminates reader confusion.
Fix 2 — Delete orphaned
contracts/stream_contract/src/stream_contract/subtreeDeleted:
contracts/stream_contract/src/stream_contract/src/test.rs(61 lines)Fixes #535
A nested
stream_contract/src/directory existed inside the realsrc/.lib.rsdeclaresmod test;, which Rust resolves tosrc/test.rs(the 2 349-line real suite) — the nested path is never on the module search path and was therefore never compiled or run.The 61-line file contained a single
fuzz_stream_invariantstest exercising four arithmetic invariants. All four are already covered by dedicated tests in the realsrc/test.rs:withdrawn <= depositedtest_fuzz_withdrawn_never_exceeds_depositedclaimable <= remainingtest_fuzz_claimable_never_exceeds_remainingrate * elapsed >= 0test_fuzz_claimable_overflow_and_cancel_invariantscancel_refund + withdrawn <= depositedtest_fuzz_cancel_early_refundsImpact: No test coverage lost. Removes confusing dead directory from code navigation and search results.
Checklist
if stream.pausedblock removed fromwithdrawcontracts/stream_contract/src/stream_contract/directory deletedcargo testscope unaffected (only dead code removed)